﻿using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace System.ComponentModel.Composition.Factories
{
    // This class deliberately does not create instances of ImportDefinition,
    // so as to test other derived classes from ImportDefinition.
    internal static partial class ImportDefinitionFactory
    {
        public static ImportDefinition Create()
        {
            return Create((Expression<Func<ExportDefinition, bool>>)null);
        }

        public static ImportDefinition Create(string contractName)
        {
            return Create(contractName, ImportCardinality.ExactlyOne, true, false);
        }

        public static ImportDefinition Create(string contractName, ImportCardinality cardinality, bool isRecomposable, bool isPrerequisite)
        {
            return new DerivedContractBasedImportDefinition(contractName, cardinality, isRecomposable, isPrerequisite);
        }

        public static ImportDefinition Create(string contractName, bool isRecomposable)
        {
            return new DerivedContractBasedImportDefinition(contractName, ImportCardinality.ExactlyOne, isRecomposable, false);
        }

        public static ImportDefinition Create(string contractName, bool isRecomposable, bool isPrerequisite)
        {
            return new DerivedContractBasedImportDefinition(contractName, ImportCardinality.ExactlyOne, isRecomposable, isPrerequisite);
        }

        public static ImportDefinition Create(Expression<Func<ExportDefinition, bool>> constraint)
        {
            return Create(constraint, ImportCardinality.ExactlyOne, true, false);
        }

        public static ImportDefinition Create(Expression<Func<ExportDefinition, bool>> constraint, ImportCardinality cardinality, bool isRecomposable, bool isPrerequisite)
        {
            return new DerivedImportDefinition(constraint, cardinality, isRecomposable, isPrerequisite);
        }
    }
}
